package com.zone.defaults;

import com.zone.MapperRegistry;
import com.zone.SqlSession;

/**
 * @author: zongzi
 * @description: TODO
 * @date: 2023/11/29
 */
public class DefaultSqlSession implements SqlSession {

    /**
     * 注入映射器注册器，通过该类获取映射器代理
     */
    private MapperRegistry mapperRegistry;

    public DefaultSqlSession(MapperRegistry mapperRegistry) {
        this.mapperRegistry = mapperRegistry;
    }


    @Override
    public <T> T selectOne(String statement) {
        // TODO 实现后续补充
        return (T) ("你的类已被代理：" + statement);
    }

    @Override
    public <T> T selectOne(String statement, Object params) {
        // TODO 实现后续补充
        return (T) ("你的类已被代理：" + statement + "参数：" + params);
    }

    @Override
    public <T> T getMapper(Class<T> clazz) {
        return mapperRegistry.getMapper(clazz, this);
    }
}
